// var host="http://39.107.232.215:8080/ke/"
// var host="http://localhost:8081/"
var host="http://ty108.com/answerThree/"
// var host="http://ty108.com/answerTwo/"
// var host="http://ty108.com/answerThree/"
// var host="http://localhost:8080/"
function ajaxpost(url,data1,fnsucc) {
    try{
        $.ajax({
            type:"post",
            url:host+url.trim(),
            data:JSON.stringify(data1),
            dataType:'json',
            contentType: "application/json",//(可以)
            headers:{'jwt':localStorage.getItem("jwt")},
            //header('Access-Control-Allow-Origin:*'),
            //contentType: "application/json; charset=utf-8",//(可以)
            //headers:"Access-Control-Allow-Origin:'*'",
//				beforeSend: function(request) {
//                      request.setRequestHeader("contentType", "application/json; charset=utf-8");
//                  },
            async:true,
            success:function(data){
                // if(data=="1"){
                //     window.parent.location.href=(host+"/logins.html");
                //     return null;
                // }
                fnsucc(data);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                setTimeout(function () {
                    layer.msg("这个请求有点懵");
                }, 1000);
                console.log(XMLHttpRequest.status);
                console.log(XMLHttpRequest.readyState);
                console.log(textStatus);
                console.log(errorThrown)
            }
        });
    }catch (e)
    {
        localStorage.removeItem("area")
        window.parent.location=host+"logins.html"
    }
}

function ajaxget(url,data1,fnsucc) {
    try{
        $.ajax({
            type:"get",
            url:host+url.trim(),
            data:data1,
            // contentType: "application/x-www-form-urlencoded",//(可以)
            headers:{'jwt':localStorage.getItem("jwt")},
            //header('Access-Control-Allow-Origin:*'),
            contentType: "application/json; charset=utf-8",//(可以)
            //headers:"Access-Control-Allow-Origin:'*'",
//				beforeSend: function(request) {
//                      request.setRequestHeader("contentType", "application/json; charset=utf-8");
//                  },
            async:true,
            success:function(data){

                fnsucc(data);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                setTimeout(function () {
                    layer.msg("网络请求失败");
                }, 1000);
                console.log(XMLHttpRequest.status);
                console.log(XMLHttpRequest.readyState);
                console.log(textStatus);
                console.log(errorThrown)
            }
        });
    }catch (e)
    {
        console.log(e)
        // localStorage.removeItem("area")
        // window.parent.location=host+"logins.html"
    }
}


function loginAjax(url,data1,fnsucc) {
    try {
        $.ajax({
            type:"post",
            url:host+url.trim()+"?a="+parseInt(10*Math.random()),
            data:data1,
            dataType:'json',
            contentType: "application/x-www-form-urlencoded",//(可以)
            //header('Access-Control-Allow-Origin:*'),
            //contentType: "application/json; charset=utf-8",//(可以)
            //headers:"Access-Control-Allow-Origin:'*'",
//				beforeSend: function(request) {
//                      request.setRequestHeader("contentType", "application/json; charset=utf-8");
//                  },
            async:true,
            success:function(data){
                fnsucc(data);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest.status);
                console.log(XMLHttpRequest.readyState);
                console.log(textStatus);
            }
        });

    }catch (e)
    {
        localStorage.removeItem("area")
        window.parent.location=host+"/logins.html"
    }

}
function ajaxjson(url,data1,fnsucc) {
    try {
        $.ajax({
            type:"post",
            url:host+url.trim()+"?a="+parseInt(10*Math.random()),
            data:JSON.stringify(data1),
            dataType:'json',
            //contentType: "application/x-www-form-urlencoded",//(可以)
            headers:{'jwt':localStorage.getItem("jwt")},
            //header('Access-Control-Allow-Origin:*'),
            contentType: "application/json; charset=utf-8",//(可以)
            //headers:"Access-Control-Allow-Origin:'*'",
//				beforeSend: function(request) {
//                      request.setRequestHeader("contentType", "application/json; charset=utf-8");
//                  },
            async:true,
            success:function(data){
                if(data=="1"){
                    window.parent.location.href=("logins.html");
                    return null;
                }
                fnsucc(data);
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                console.log(XMLHttpRequest.status);
                console.log(XMLHttpRequest.readyState);
                console.log(textStatus);
            }
        });
    }catch (e)
    {
        localStorage.removeItem("area")
        window.parent.location=host+"/logins.html"
    }
}